package com.lou.springboot.common;

import com.lou.springboot.enums.ResultEnum;

import java.io.Serializable;

public class ResultVOUtil<T> implements Serializable {

    public ResultVOUtil(){}

    public static <T> ResultVO success(){
        ResultVO resultVO = new ResultVO();
        resultVO.setMessage("成功");
        resultVO.setResultCode(0);
        return resultVO;
    }

    public static <T> ResultVO success(T data){
        ResultVO resultVO = new ResultVO();
        resultVO.setData(data);
        resultVO.setMessage("成功");
        resultVO.setResultCode(0);
        return resultVO;
    }

    public static <T> ResultVO success(T data, String message, int resultCode){
        ResultVO resultVO = new ResultVO();
        resultVO.setData(data);
        resultVO.setMessage(message);
        resultVO.setResultCode(resultCode);
        return resultVO;
    }

    public static ResultVO error(String message, int resultCode){
        ResultVO resultVO = new ResultVO();
        resultVO.setMessage(message);
        resultVO.setResultCode(resultCode);
        return resultVO;
    }

    public static ResultVO error(ResultEnum resultEnum){
        ResultVO resultVO = new ResultVO();
        resultVO.setMessage(resultEnum.message);
        resultVO.setResultCode(resultEnum.code);
        return resultVO;
    }

    public static ResultVO error(String message){
        ResultVO resultVO = new ResultVO();
        resultVO.setMessage(message);
        resultVO.setResultCode(400);
        return resultVO;
    }

}